<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

/**
 * 考勤信息数据表
 *
 * Date: 19/03/2018
 * @author George
 */
class CreateAttendancesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('attendances', function (Blueprint $table) {
            $table->increments('id');
            $table->unsignedInteger('user_id')->index()->comment('用户ID');
            $table->unsignedInteger('company_id')->index()->comment('公司ID');
            $table->unsignedInteger('project_id')->index()->comment('项目ID');
            $table->unsignedInteger('schedule_id')->index()->comment('排班ID');
			$table->decimal('checkin_longitude', 10, 7)->comment('签到经度');
			$table->decimal('checkin_latitude', 10, 7)->comment('签到纬度');
			$table->string('checkin_address')->nullable()->comment('签到地址');
			$table->string('checkin_example')->comment('签到示例图');
			$table->string('checkin_image')->comment('签到图片');
			$table->timestamp('checkin_time')->comment('签到时间');
			$table->string('checkin_status')->index()->default('')->comment('签到状态');
			$table->decimal('checkout_longitude', 10, 7)->nullable()->comment('签退经度');
			$table->decimal('checkout_latitude', 10, 7)->nullable()->comment('签退纬度');
			$table->string('checkout_address')->nullable()->nullable()->comment('签退地址');
			$table->string('checkout_example')->nullable()->comment('签退示例图');
			$table->string('checkout_image')->nullable()->comment('签退图片');
			$table->timestamp('checkout_time')->nullable()->comment('签退时间');
			$table->string('checkout_status')->index()->default('')->comment('签退状态');
			$table->integer('genre_id')->index()->comment('班次ID');
			$table->string('genre_name')->index()->comment('班次类型');
			$table->unique(['user_id', 'schedule_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('attendances');
    }
}
